package com.ityedao.IO序列化流;

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;

public class MutObjectOutputStream {
    public static void main(String[] args) {
        try (ObjectOutputStream obs =
                     new ObjectOutputStream(
                             new FileOutputStream("src/IO流-序列化多个对象.txt"));
        ) {
            List<User> users = new ArrayList<>();
            users.add(new User("admin1", "李四", "dja;l58", 23));
            users.add(new User("admin2", "赵六", "djadjffda8", 45));
            users.add(new User("admin3", "王五", "dja;oj8", 23));
            obs.writeObject(users);
            System.out.println("序列化成功！");
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
